﻿///////////////////////////////////////////////////////////////////////////////
// Activity: program.activity0
// ArmMover type definitions
///////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml;

using ccr = Microsoft.Ccr.Core;
using dss = Microsoft.Dss.Core;
using dssa = Microsoft.Dss.Core.Attributes;
using dssh = Microsoft.Dss.Core.DsspHttp;
using dssm = Microsoft.Dss.ServiceModel.DsspServiceBase;
using dssp = Microsoft.Dss.ServiceModel.Dssp;
using soap = W3C.Soap;

using submgr = Microsoft.Dss.Services.SubscriptionManager;

namespace Robotics.MoveArm_Sim2.ArmMover
{
    static class Contract
    {
        public const string Identifier = "http://schemas.tempuri.org/2008/02/movearm_sim2/armmover.html";
    }

    [dssa.DataContract]
    public class ArmMoverState
    {
        float _base0;
        [dssa.DataMember]
        public float Base0
        {
            get { return _base0; }
            set { _base0 = value; }
        }

        int _pollInterval;
        [dssa.DataMember]
        public int PollInterval
        {
            get { return _pollInterval; }
            set { _pollInterval = value; }
        }

        float _shoulder1;
        [dssa.DataMember]
        public float Shoulder1
        {
            get { return _shoulder1; }
            set { _shoulder1 = value; }
        }

        float _elbow2;
        [dssa.DataMember]
        public float Elbow2
        {
            get { return _elbow2; }
            set { _elbow2 = value; }
        }

        float _wrist3;
        [dssa.DataMember]
        public float Wrist3
        {
            get { return _wrist3; }
            set { _wrist3 = value; }
        }

        float _gripper5;
        [dssa.DataMember]
        public float Gripper5
        {
            get { return _gripper5; }
            set { _gripper5 = value; }
        }

        float _wristRotate4;
        [dssa.DataMember]
        public float WristRotate4
        {
            get { return _wristRotate4; }
            set { _wristRotate4 = value; }
        }
    }

    #region Custom message types

    [dssa.DataContract]
    public class SetPollIntervalRequest
    {
        int _pollInterval;
        [dssa.DataMember]
        public int PollInterval
        {
            get { return _pollInterval; }
            set { _pollInterval = value; }
        }
    }

    [dssa.DataContract]
    public class SetPollIntervalResponse
    {
    }

    #endregion

    #region Operations Port

    public class ArmMoverOperations : ccr.PortSet
    {
        public ArmMoverOperations() : base (
            typeof(dssp.DsspDefaultLookup),
            typeof(dssp.DsspDefaultDrop),
            typeof(dssh.HttpGet),
            typeof(SetPollInterval),
            typeof(Get),
            typeof(Replace),
            typeof(Subscribe)
        )
        {
        }

        public static implicit operator ccr.Port<dssp.DsspDefaultLookup>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<dssp.DsspDefaultLookup>)portSet[typeof(dssp.DsspDefaultLookup)];
        }

        public void Post(dssp.DsspDefaultLookup msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<dssp.DsspDefaultDrop>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<dssp.DsspDefaultDrop>)portSet[typeof(dssp.DsspDefaultDrop)];
        }

        public void Post(dssp.DsspDefaultDrop msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Get>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Get>)portSet[typeof(Get)];
        }

        public void Post(Get msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Replace>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Replace>)portSet[typeof(Replace)];
        }

        public void Post(Replace msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<Subscribe>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<Subscribe>)portSet[typeof(Subscribe)];
        }

        public void Post(Subscribe msg)
        {
            base.PostUnknownType(msg);
        }

        public static implicit operator ccr.Port<SetPollInterval>(ArmMoverOperations portSet)
        {
            if (portSet == null)
            {
                return null;
            }
            return (ccr.Port<SetPollInterval>)portSet[typeof(SetPollInterval)];
        }

        public void Post(SetPollInterval msg)
        {
            base.PostUnknownType(msg);
        }

        public dssp.DsspResponsePort<SetPollIntervalResponse> SetPollInterval(SetPollIntervalRequest body)
        {
            SetPollInterval message = new SetPollInterval();
            message.Body = body;

            this.Post(message);

            return message.ResponsePort;
        }

        public dssp.DsspResponsePort<dssp.SubscribeResponseType> Subscribe(ccr.IPort notificationPort)
        {
            Subscribe message = new Subscribe();
            message.NotificationPort = notificationPort;

            this.Post(message);

            return message.ResponsePort;
        }
    }

    #endregion

    #region Standard DSSP message definitions

    [Description("Retrieves the current state of the service")]
    public class Get : dssp.Get<dssp.GetRequestType, dssp.DsspResponsePort<ArmMoverState>>
    {
    }

    [Description("Sets the current state of the service.\nThis is raised as an event whenever the state changes.")]
    public class Replace : dssp.Replace<ArmMoverState, dssp.DsspResponsePort<dssp.DefaultReplaceResponseType>>
    {
    }

    public class Subscribe : dssp.Subscribe<dssp.SubscribeRequestType, dssp.DsspResponsePort<dssp.SubscribeResponseType>>
    {
    }

    #endregion

    #region Custom message definitions

    public class SetPollInterval : dssp.Update<SetPollIntervalRequest, dssp.DsspResponsePort<SetPollIntervalResponse>>
    {
    }

    #endregion
}
